﻿using System;

using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.WowAddonStudio.Lua.LanguageService.Model;

using NUnit.Framework;

namespace Microsoft.WowAddonStudio.Lua.LanguageService.Tests
{
    [TestFixture]
    public class LuaLanguageServiceTest
    {
        private LuaLanguageService languageService;

        [SetUp]
        public void SetUp()
        {
            languageService = new LuaLanguageService();
            languageService.Initialize();
        }

        [Test]
        public void EmptyFileCompleteWordDeclarationsTest()
        {
            var authoringSink = new LuaAuthoringSink(ParseReason.CompleteWord, 1, 1, 50);
            var info = new TokenInfo();
            const IVsTextView view = null;

            var request = new LuaParseRequest(1, 1, info, String.Empty, "test.lua", ParseReason.CompleteWord, view, authoringSink, true);
            var authoringScope = languageService.ParseSource(request);
            Assert.IsNotNull(authoringScope);

            var declarations = authoringScope.GetDeclarations(view, 1, 1, info, ParseReason.CompleteWord);
            Assert.IsNotNull(declarations);
            Assert.AreNotEqual(0, declarations.GetCount());
        }
    }
}
